package com.army.study.slice;

import com.army.study.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.webengine.WebConfig;
import ohos.agp.components.webengine.WebView;

public class MainAbilitySlice extends AbilitySlice {
    private static final String URL_LOCAL = "dataability://com.army.study.ExampleDataAbility/resources/rawfile/test.html";

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        
        initComponent();
    }

    private void initComponent() {
        WebView webView = (WebView) findComponentById(ResourceTable.Id_webview);
        // 配置是否支持访问DataAbility资源，默认为true
        WebConfig webConfig = webView.getWebConfig();
        webConfig.setDataAbilityPermit(true);
        webView.load(URL_LOCAL);

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
